package com.liefox.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        /**
         * 医生页
         * */
        /*欢迎页*/
        registry.addViewController("/").setViewName("doctor/sign-in");
        /*首页*/
        registry.addViewController("/index").setViewName("doctor/index");
        /*去登录*/
        registry.addViewController("/tosign-in").setViewName("doctor/sign-in");
        /*去注册*/
        registry.addViewController("/tosign-up").setViewName("doctor/sign-up");
        /*去忘记密码*/
        registry.addViewController("/torecoverpw").setViewName("doctor/pages-recoverpw");
        /*去修改个人信息*/
        registry.addViewController("/topro-edit").setViewName("doctor/main/profile-edit");
        /*去邮箱*/
        registry.addViewController("/toemail").setViewName("doctor/app/email-compose");
        /*去编辑病患表格*/
        registry.addViewController("/totable").setViewName("doctor/app/table-editable");
        /*去修改病患信息*/
        registry.addViewController("/toRePatientInfo").setViewName("doctor/app/rePatientInfo");
        /*去增加病患信息*/
        registry.addViewController("/toAddPatientInfo").setViewName("doctor/app/addPatientInfo");
        /*去群聊天*/
        registry.addViewController("/toChat").setViewName("doctor/main/chat");


        /**
         * 医生页
         * */
        /**
         * 患者页
         * */


        /*患者去登录*/
        registry.addViewController("/tosuffer-sign-in").setViewName("suffer/suffer-sign-in");
        /*患者去注册*/
        registry.addViewController("/tosuffer-sign-up").setViewName("suffer/suffer-sign-up");
        /*患者首页*/
        registry.addViewController("/tosufferIndex").setViewName("suffer/sufferIndex");

        /**
         * 患者页
         * */
        /**
         * 管理员页
         * */


        /*去登录*/
        registry.addViewController("/toadmin-sign-in").setViewName("admin/admin-sign-in");
        registry.addViewController("/toadminIndex").setViewName("admin/adminIndex");

        /**
         * 管理员页
         * */
    }

    //自定义的国际化就生效了
    @Bean
    public LocaleResolver localeResolver() {
        return new MyLocaleResolver();
    }


    //配置登录拦截器
    /*@Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandlerInterceptor())
                *//*拦截*//*
                .addPathPatterns("/**")
                *//*放行*//*
                .excludePathPatterns(
                        "/tosign-in"
                        , "/tosign-up"
                        , "/sign-in"
                        , "/sign-up"
                        , "/torecoverpw"
                        , "/recPwEmail"
                        , "/recPw"
                        , "/"
                        , "/css/**"
                        , "/js/**"
                        , "/images/**"

                        , "/suffer-sign-in"
                        , "/suffer-sign-up"
                        , "/admin-sign-in"
                        , "/app/**"
                        , "/fonts/**"
                        , "/fullcalendar/**"
                );
    }*/


}
